#pragma once

#include <vector>
#include "BaseReader.h"
#include "BaseWriter.h"

class CIniItem
{
public:
  CIniItem() : m_nSection(-1) {}

  void SetSection(int s)           { m_nSection = s; }
  void SetName(const TCHAR* s)     { m_sVarName = s; }
  void SetValue(const TCHAR* s)    { m_sVarValue = s; }
  void SetComments(const TCHAR* s) { m_sVarComments = s; }

  int             GetSection() const  { return m_nSection; }
  const CString&  GetName() const     { return m_sVarName; }
  const CString&  GetValue() const    { return m_sVarValue; }
  const CString&  GetComments() const { return m_sVarComments; }

protected:
  int       m_nSection;
  CString   m_sVarName;
  CString   m_sVarValue;
  CString   m_sVarComments;
};

class CIniData
{
  typedef std::vector<CString>   CSectionList;
  typedef std::vector<CIniItem*> CItemList;

public:
  CIniData()
  {}
  ~CIniData()
  { Clear(); }

  bool Load(CBaseReader& fr);
  bool Save(CBaseWriter& fw) const;

  void Clear();

  CIniItem* FindItem(const CString& name);

public:
  CSectionList m_Sections;
  CItemList    m_Items;
};